package aa;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;

public class GetPic {

	public static void main(String[] args) throws Exception {
		HttpClient client = new DefaultHttpClient();
		HttpUriRequest request = new HttpGet("http://10.50.254.182:8080/studio/getpic");
		HttpResponse resp = client.execute(request);
        InputStream in = resp.getEntity().getContent();
        String path="C:/Users/PC/Desktop/aa.jpg";
		File file=new File(path);
		if(!file.exists()){
			file.createNewFile();}
			FileOutputStream os = new FileOutputStream(file);
			byte[] buffer = new byte[1024];
			int length = 0 ;
			while((length = in.read(buffer))>0){
				os.write(buffer, 0, length);
			}
			in.close();
			os.close();
        
        
		
	}

}
